//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "server\fn_serverSetupPickup.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_object","_action","_instance_id","_parameters","_action_id","_shared_variable","_initial_status"];
DEFAULT_PARAM(_object,TMF_REGISTER_OBJECT,objNull);
DEFAULT_PARAM(_action,TMF_REGISTER_ACTION,[]);
DEFAULT_PARAM(_instance_id,TMF_REGISTER_INSTANCE,TMF_SERVER_INSTANCE_ID);

if (!isnull _object) then {
	_action_id = [_action] call FFUNC(actionGetID);
	TRACE_1("Action",_action);
	_parameters = [_action] call FFUNC(actionGetParams);
	_shared_variable = [_parameters, "SHARED_VAR", ""] call CFUNC(hashGet);
	_initial_status = false; //[_parameters, "SHARED_VAR_VAL", false] call CFUNC(hashGet);

	_obj_var = format["mission_object_pickedup_%1",_action_id];
	OSETVARP(_object,_obj_var,_initial_status);
	if (!isNil "_shared_variable") then {
		if (_shared_variable != "") then {
			[_instance_id,_shared_variable,_initial_status] call FFUNC(setMissionJIPVar);
			[QGVAR(all_var), [_instance_id,_shared_variable,_initial_status],THIS_FILE_] call NFUNC(callEvent);
		};
	};
	_action = [_action, _initial_status] call FFUNC(actionSetEvent);
	[_object, _action] call FFUNC(actionSet);
	_object allowDamage false;
} else {
	ERROR("Object not set");
};

TRACE("End");
TMFPROFILERSTOP;